package cn.aws360.boot.wechat.biz.mp.builder;

import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage;

/**
 * @author junnan
 */
public class WxMpOutBuilder {

    public static WxMpXmlOutMessage buildText(WxMpXmlMessage inMessage, String content) {
        return WxMpXmlOutMessage.TEXT().content(content)
                .fromUser(inMessage.getToUser()).toUser(inMessage.getFromUser())
                .build();
    }

    public static WxMpXmlOutMessage buildVoice(WxMpXmlMessage inMessage, String mediaId) {
        return WxMpXmlOutMessage.VOICE().mediaId(mediaId)
                .fromUser(inMessage.getToUser()).toUser(inMessage.getFromUser())
                .build();
    }

    public static WxMpXmlOutMessage buildImage(WxMpXmlMessage inMessage, String mediaId) {
        return WxMpXmlOutMessage.IMAGE().mediaId(mediaId)
                .fromUser(inMessage.getToUser()).toUser(inMessage.getFromUser())
                .build();
    }

    public static WxMpXmlOutMessage buildVideo(WxMpXmlMessage inMessage, String mediaId, String title, String description) {
        return WxMpXmlOutMessage.VIDEO().mediaId(mediaId).title(title).description(description)
                .fromUser(inMessage.getToUser()).toUser(inMessage.getFromUser())
                .build();
    }

    public static WxMpXmlOutMessage buildMusic(WxMpXmlMessage inMessage, String mediaId, String title, String description, String musicUrl) {
        return WxMpXmlOutMessage.MUSIC().thumbMediaId(mediaId).title(title).description(description)
                .musicUrl(musicUrl).hqMusicUrl(musicUrl)
                .fromUser(inMessage.getToUser()).toUser(inMessage.getFromUser())
                .build();
    }

    public static WxMpXmlOutMessage buildNews(WxMpXmlMessage inMessage, String url, String title, String description, String picUrl) {
        WxMpXmlOutNewsMessage.Item item = new WxMpXmlOutNewsMessage.Item();
        item.setTitle(title);
        item.setDescription(description);
        item.setUrl(url);
        item.setPicUrl(picUrl);
        return WxMpXmlOutMessage.NEWS().addArticle(item)
                .fromUser(inMessage.getToUser()).toUser(inMessage.getFromUser())
                .build();
    }

}
